/**
 * @author YinHang
 */
;(function () {
	var g2d = Gamepackage.get("Gamepackage.ui.g2d");
	g2d.Image = function (src) {
		this.src = src;
		this.sourceImage = new Image();
		this.loaded = false;
		this.setVisible(true);
		this.setX(0);
		this.setY(0);
	};
	
	Gamepackage.extend(g2d.Image, g2d.Displayable);
	var Prototype = g2d.Image.prototype;
	
	Prototype.load = function (callback) {
		var host = this;
		this.sourceImage.onload = function () {
			host.setWidth(host.sourceImage.width);
			host.setHeight(host.sourceImage.height);
			host.loaded = true;
			if(callback)
				callback();
		};
		this.sourceImage.src = this.src;
	};
	
	Prototype.getSourceImage = function () {
		return this.sourceImage;
	};
	
	Prototype.draw = function (graphics) {
		graphics.drawImage(this, this.x, this.y, this.width, this.height);
	};
})();
